import 'package:flutter2/generated/json/base/json_convert_content.dart';
import 'package:flutter2/model/product_entity.dart';

ProductEntity $ProductEntityFromJson(Map<String, dynamic> json) {
  final ProductEntity productEntity = ProductEntity();
  final List<ProductDetail>? details = (json['uturkey'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ProductDetail>(e) as ProductDetail).toList();
  if (details != null) {
    productEntity.details = details;
  }
  final int? pid = jsonConvert.convert<int>(json['blankfollowsharpen']);
  if (pid != null) {
    productEntity.pid = pid;
  }
  return productEntity;
}

Map<String, dynamic> $ProductEntityToJson(ProductEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uturkey'] = entity.details.map((v) => v.toJson()).toList();
  data['blankfollowsharpen'] = entity.pid;
  return data;
}

extension ProductEntityExtension on ProductEntity {
  ProductEntity copyWith({
    List<ProductDetail>? details,
    int? pid,
  }) {
    return ProductEntity()
      ..details = details ?? this.details
      ..pid = pid ?? this.pid;
  }
}

ProductDetail $ProductDetailFromJson(Map<String, dynamic> json) {
  final ProductDetail productDetail = ProductDetail();
  final int? duration = jsonConvert.convert<int>(json['word']);
  if (duration != null) {
    productDetail.duration = duration;
  }
  final int? period = jsonConvert.convert<int>(json['kindsheetmake']);
  if (period != null) {
    productDetail.period = period;
  }
  final int? detailId = jsonConvert.convert<int>(json['areboilruin']);
  if (detailId != null) {
    productDetail.detailId = detailId;
  }
  final int? min = jsonConvert.convert<int>(json['entertainmentaccountinsixth']);
  if (min != null) {
    productDetail.min = min;
  }
  final int? max = jsonConvert.convert<int>(json['assumeagobutton']);
  if (max != null) {
    productDetail.max = max;
  }
  final int? internal = jsonConvert.convert<int>(json['frenchcirculate']);
  if (internal != null) {
    productDetail.internal = internal;
  }
  return productDetail;
}

Map<String, dynamic> $ProductDetailToJson(ProductDetail entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['word'] = entity.duration;
  data['kindsheetmake'] = entity.period;
  data['areboilruin'] = entity.detailId;
  data['entertainmentaccountinsixth'] = entity.min;
  data['assumeagobutton'] = entity.max;
  data['frenchcirculate'] = entity.internal;
  return data;
}

extension ProductDetailExtension on ProductDetail {
  ProductDetail copyWith({
    int? duration,
    int? period,
    int? detailId,
    int? min,
    int? max,
    int? internal,
  }) {
    return ProductDetail()
      ..duration = duration ?? this.duration
      ..period = period ?? this.period
      ..detailId = detailId ?? this.detailId
      ..min = min ?? this.min
      ..max = max ?? this.max
      ..internal = internal ?? this.internal;
  }
}